package com.aube.rvi.module;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by huyaonan on 16/10/21.
 */
public class ModuleItem implements Serializable {
    public String packagename;
    public String md5;
    public String download;
    public String themeCode;

    public String getFileName() {
        return themeCode + ".apk";
    }

    public static ModuleItem parseResponse(String s) {
        try {
            JSONObject object = new JSONObject(s);
            JSONObject item = object.optJSONObject("data");
            if(item != null) {
                ModuleItem moduleItem = new ModuleItem();
                moduleItem.packagename = item.optString("packagename");
                moduleItem.md5 = item.optString("md5");
                moduleItem.download = item.optString("download");
                moduleItem.themeCode = item.optString("themeCode");
                return moduleItem;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}